﻿using gt.webapi.core.Entity.Throttle;
using gt.webapi.core.Repositories;
using gt.webapi.core.Repositories.Impl;
using System;
using System.Collections.Generic;

namespace gt.webapi.core.Entity.Options
{
    public class RateLimitOption
    {
        private IRateLimitRepository m_repository = null;

        public RateLimitOption(IRateLimitRepository repository)
        {
            this.m_repository = repository ?? throw new ArgumentNullException("repository");
        }

        public RateLimitOption(string appkey, Dictionary<RateLimitPeriod, int> rule)
            : this(new MemoryRateLimitRepository())
        {
            this.m_repository.SupplerRateLimitRule(appkey, rule);
        }

        public IRateLimitRepository Repository { get { return m_repository; } }
    }
}
